"""
python 优化框架
"""
import numpy as np
from CEC.CEC_Fun import CEC
from utils.FitnessPlot import FitPlot
from Origin import WOA, HHO

algorithm_names = ['WOA', 'HHO']
Gbest_curves = []
Test_names = ['F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12', 'F13', 'F14',
              'F15', 'F16', 'F17', 'F18', 'F19', 'F20', 'F21', 'F22', 'F23', 'F24', 'F25', 'F26', 'F27', 'F28', 'F29']
population_size = 30
dim = 30
max_iter = dim*10000
LB = -10 * np.ones(dim)
UB = 10 * np.ones(dim)
for algorithm_name in algorithm_names:
    for test_name in Test_names:
        Func = CEC(year=2017, dim=dim, test_name=test_name)
        FitFunction = Func.fobj
        b = 2
        Gbest_curve, GbestX = WOA.WOA(FitFunction, LB=LB, UB=UB,
                                      dim=dim, b=b, population_size=population_size, max_iter=max_iter).Optimize()
        Gbest_curves.append(Gbest_curve)
        Gbest_curve, GbestX = HHO.HHO(FitFunction, LB=LB, UB=UB,
                                      dim=dim, b=b, population_size=population_size, max_iter=max_iter).Optimize()
        Gbest_curves.append(Gbest_curve)
        print(Gbest_curves)
        # 可视化训练图像
        fitness_plot = FitPlot(algorithm_names, Gbest_curves, test_name)
        fitness_plot.plot_and_save()
        Gbest_curves = []
